#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

using ll = long;
class SegTree {
	vector<ll> sum;
	vector<ll> add;

	void up(int i)
	{
		sum[i] = sum[i << 1] + sum[(i << 1) | 1];
	}

	void down(int i, int ln, int rn)
	{
		if (add[i]) {
			lazy(i << 1, add[i], ln);
			lazy((i << 1) | 1, add[i], rn);
			add[i] = 0;
		}
	}

	void lazy(int i, ll v, int n)
	{
		sum[i] += v * n;
		add[i] += v;
	}

    public:
	void build(int l, int r, int i, vector<ll> &arr)
	{
		if (l == r) {
			sum[i] = arr[l];
		} else {
			int mid = (l + r) >> 1;
			build(l, mid, i << 1, arr);
			build(mid + 1, r, (i << 1) | 1, arr);
			up(i);
		}
		add[i] = 0;
	}

	void radd(int jobl, int jobr, ll v, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			lazy(i, v, r - l + 1);
			return;
		}
		int mid = (l + r) >> 1;
		down(i, mid - l + 1, r - mid);
		if (jobl <= mid) {
			radd(jobl, jobr, v, l, mid, i << 1);
		}
		if (mid < jobr) {
			radd(jobl, jobr, v, mid + 1, r, (i << 1) | 1);
		}
		up(i);
	}

	ll query(int jobl, int jobr, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			return sum[i];
		}
		ll ans = 0;
		int mid = (l + r) >> 1;
		down(i, mid - l + 1, r - mid);
		if (jobl <= mid) {
			ans += query(jobl, jobr, l, mid, i << 1);
		}
		if (mid < jobr) {
			ans += query(jobl, jobr, mid + 1, r, (i << 1) | 1);
		}
		return ans;
	}

    public:
	SegTree(int n, vector<ll> &arr) : sum(4 * n, 0), add(4 * n, 0)
	{
		build(1, n, 1, arr);
	}
};

int main()
{
	int n, m;
        
        // ios::sync_with_stdio(false);
	// cin.tie(NULL); cout.tie(NULL);

	cin >> n >> m;
	vector<ll> arr(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	SegTree segtree(n, arr);
        
        ll v;
	for (int i = 0, op, l, r; i < m; i++) {
		cin >> op >> l >> r;
		if (op == 2) {
			cout << segtree.query(l, r, 1, n, 1) << endl;
		} else {
			cin >> v;
			segtree.radd(l, r, v, 1, n, 1);
		}
	}
	return 0;
}